package com.l024.framework.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.l024.framework.R;
import com.moxun.tagcloudlib.view.TagsAdapter;

import java.util.List;

/**
* @Author  wu_ming_zhi_bei
* @Date   2020/3/1 22:31
* @Notes  3d星球适配器
*/
public class CloudTagAdapter extends TagsAdapter {
    private Context mContext;
    private List<String> mList;
    private LayoutInflater inflater;

    public CloudTagAdapter(Context mContext, List<String> mList) {
        this.mContext = mContext;
        this.mList = mList;
        //从服务中获取Inflater
        inflater =(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public View getView(Context context, int position, ViewGroup parent) {
        //初始化View
        View view = inflater.inflate(R.layout.layout_star_view_item,null);
        //初始化控件
        ImageView ivStarIcon = view.findViewById(R.id.iv_star_icon);
        TextView ivStarText =  view.findViewById(R.id.tv_star_name);
        //赋值
        ivStarText.setText(mList.get(position));
        //随机设置图片
        switch (position%10){
            case 0:{
                ivStarIcon.setImageResource(R.drawable.icon_3);
                break;
            }
            case 1:{
                ivStarIcon.setImageResource(R.drawable.icon_3);
                break;
            }
            case 2:{
                ivStarIcon.setImageResource(R.drawable.icon_3);
                break;
            }
            case 3:{
                ivStarIcon.setImageResource(R.drawable.icon_4);
                break;
            }
            case 4:{
                ivStarIcon.setImageResource(R.drawable.icon_5);
                break;
            }
            case 5:{
                ivStarIcon.setImageResource(R.drawable.icon_6);
                break;
            }
            case 6:{
                ivStarIcon.setImageResource(R.drawable.icon_7);
                break;
            }
            default:{
                ivStarIcon.setImageResource(R.drawable.icon_8);
                break;
            }
        }
        return view;
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public int getPopularity(int position) {
        return 7;
    }

    @Override
    public void onThemeColorChanged(View view, int themeColor) {

    }
}
